Skip to content

feat: support Invidious image proxy endpoints#257

Closed
hikiko4ern wants to merge 2 commits intoTeamPiped:mainfrom
hikiko4ern:invidious-proxy-images
Closed

feat: support Invidious image proxy endpoints#257
hikiko4ern wants to merge 2 commits intoTeamPiped:mainfrom
hikiko4ern:invidious-proxy-images

Conversation

@hikiko4ern
Copy link
Copy Markdown

@hikiko4ern hikiko4ern commented Nov 11, 2024

So, this is an attempt to add support for Invidious-specific image endpoints.
I marked PR as a draft because I have some questions about expected behavior.

closes #111

Comment thread src/main.rs
}

#[cfg(feature = "invidious")]
if matches!(req.path().get(0..4), Some("/vi/") | Some("/sb/")) {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should Invidious endpoints be backwards compatible with Piped? For example, both Invidious and Piped can download video previews via /vi/, but Piped requests them with query (/vi/MYSQe4uuSOA/hq720.jpg?host=i.ytimg.com&qhash=...&rs=...&sqp=...) while Invidious requests them without query (/vi/MYSQe4uuSOA/mqdefault.jpg).

With the current approach they are not backwards compatible, so if a Piped client sends a request to a proxy with invidious feature enabled, qhash and other parameters will not be used and validated. This allows avoiding unnecessary checks for instances running only Piped or only Invidious, but will cause problems for instances running both.

If they need to be backwards compatible, a check that the query is empty could be added here, for example.

Comment thread src/transcode_image.rs
};

#[cfg(feature = "avif")]
if content_type == "image/webp" || content_type == "image/jpeg" && avif {
Copy link
Copy Markdown
Author

@hikiko4ern hikiko4ern Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this check supposed to be like that?

Suggested change
if content_type == "image/webp" || content_type == "image/jpeg" && avif {
if (content_type == "image/webp" || content_type == "image/jpeg") && avif {

Now image/webp is always transcoded regardless of the presence of avif in the query, because this check is computed as

if content_type == "image/webp" || (content_type == "image/jpeg" && avif) {

Comment thread src/transcode_image.rs
image_response: Response,
http_response: &mut HttpResponseBuilder,
#[cfg(feature = "avif")] avif: bool,
) -> Result<Either<HttpResponse, Response>, Box<dyn std::error::Error>> {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What behavior is expected in case of transcoding errors? Should the server return 500 Internal Server Error (as it is now) or the original image?

@hikiko4ern hikiko4ern closed this Oct 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Invidious endpoints

1 participant